package com.study.www.config;

import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.util.ObjectUtils;

import java.lang.annotation.Annotation;

/**
 *  获得 PO 对象上面的相关属性
 * @author : Administrator.zhuyanpeng
 * @date : 2019/10/28 - 10:09
 */
public class TableUtils {

    /**
     * 获取表名
     * @param
     * @return
     * @throws
     * @author zhuyanpeng
     * @date 2019/10/28
     */
    public static String getTableName(Class clazz){
        Document document = (Document) clazz.getAnnotation(Document.class);
        if (!ObjectUtils.isEmpty(document)){
            return  document.collection();
        }
        return null;
    }
}
